package com.yunxi.service.dubboService.impl.finance;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.finance.pojo.FinanceInstitutionVO;
import com.yunxi.finance.pojo.FinanceProductCalculateVO;
import com.yunxi.finance.pojo.FinanceProductVO;
import com.yunxi.finance.service.FinanceProductDubboService;
import com.yunxi.model.finance.FinanceProduct;
import com.yunxi.service.localService.finance.FinanceProductService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.List;

/**
 * <p>
 * 金融产品维护 服务实现类
 * </p>
 *
 * @author XUQI
 * @since 2019-12-02
 */
public class FinanceProductDubboServiceImpl implements FinanceProductDubboService {

   @Autowired
   @Qualifier(value = "financeProductServiceImpl")
   FinanceProductService financeProductService;


   @Override
   public FinanceProductVO getById(String id) {
      FinanceProduct financeProduct = financeProductService.getById(id);
      if (financeProduct == null) {
         return null;
      }
      FinanceProductVO financeProductVO = new FinanceProductVO();
      BeanUtils.copyProperties(financeProduct, financeProductVO);
      return financeProductVO;
   }

   @Override
   public ApiResult saveOrUpdate(FinanceProductVO financeProductVO) {
      return financeProductService.saveOrUpdate(financeProductVO);
   }

   @Override
   public void removeByIds(List<String> ids) {
      financeProductService.removeByIds(ids);
   }

   @Override
   public PageInfo findPageByVO(FinanceProductVO financeProductVO, Integer pageNum,
                                Integer pageSize) {
      return financeProductService.pageByVo(financeProductVO, pageNum, pageSize);
   }

   /**
    * 查询金融机构下拉框
    *
    * @return List<FinanceInstitutionVO>
    */
   @Override
   public List<FinanceInstitutionVO> findFinanceInstitutionDropDown() {
      return financeProductService.findFinanceInstitutionDropDown();
   }

   /**
    * 根据方案类型查询金融产品
    *
    * @param planType 方案类型
    * @return List<FinanceProductVO>
    */
   @Override
   public List<FinanceProductVO> productListByPlanType(String planType, LoginInfo info) {
      return financeProductService.productListByPlanType(planType, info);
   }

   /**
    * 金融产品结果计算
    */
   @Override
   public ApiResult calculate(FinanceProductCalculateVO calculateVO) {
      return financeProductService.calculate(calculateVO);
   }


   /**
    * 查询配置/选装包价格
    *
    * @param priceType 价格类型（ZVAR：选装包价格-零售指导价  ZPRR：零售价格 – 基本车型）
    * @param codes     15位码/选装包编码
    * @return ApiResult
    */
   @Override
   public ApiResult queryPrice(String priceType, List<String> codes) {
      return financeProductService.queryPrice(priceType, codes);
   }


}
